#ifndef TITLESCREENSTATE_H
#define TITLESCREENSTATE_H

#include "Singleton.h"
#include "EventHandler.h"
#include "EventPoller.h"
#include "GameState.h"
#include "Text.h"

#include <D3DX10.h>

class TitleScreenState : public Uncopyable, public GameState, public EventHandler
{
	TitleScreenState();
	friend class Singleton<TitleScreenState>;
public:
	void Update();
	void Draw();
	virtual void OnActivated();
	virtual void OnDeactivated();
	
	virtual void OnKeyDownEvent(const WPARAM& event);
	virtual void OnKeyUpEvent(const WPARAM& event);
	virtual void OnMouseMotionEvent(const LPARAM& event);
	virtual void OnMouseButtonDownEvent(const MSG& event);
	virtual void OnMouseButtonUpEvent(const MSG& event);

private:
	void HostAndPlay();
	void Join();
	void ConnectToServer();
	void CreateServer();

private:

	enum CURRENT_SELECTED_STATE
	{
		HOST_AND_PLAY = 0x00,
		JOIN = 0x01,
		EXIT = 0x02,
		MAIN = 0x04,
		CONNECTING_TO_SERVER = 0x08,
		CREATING_SERVER = 0x10
	};

	D3DXVECTOR2 m_screenSize;
	D3DXVECTOR2 m_mousePos;
	D3DXVECTOR2 m_convertedMousePos;
	bool m_mouseDown;
	CURRENT_SELECTED_STATE m_curState;
	float m_alpha;
	D3DXVECTOR4 m_col;
	Text m_text;
	std::string m_port;
	bool m_canEditPort;
	bool m_canEditServer;
	std::string m_serverIP;
	float m_spacing;
	std::string m_serverText;
	std::string m_portText;
};

typedef Singleton<TitleScreenState> TheTitleScreenState;

#endif // TITLESCREENSTATE_H